package com.atguigu.gmall.order.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: zm
 * @Date: 2021/8/15 14:17
 */
@Configuration
public class ThreadPoolConfig {


    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){

        return  new ThreadPoolExecutor(
                6,
                12,
                3L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5)
//                Executors.defaultThreadFactory(), // 线程池工厂
//                new ThreadPoolExecutor.AbortPolicy() // 拒绝策略
        );
    }
}
